package greed

func canJump(nums []int) bool {
	cnt := 0
	if len(nums) == 1 {
		return true
	}
	for i := 0; i <= cnt; i++ {
		cnt = max(cnt, nums[i] + i)
		if cnt >= len(nums) - 1 {
			return true
		}
	}
	return false
}